package com.example.module_car.view

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.bumptech.glide.Glide
import com.example.module_car.R
import com.example.module_car.databinding.ActivityCarDistinguishBinding
import com.example.module_car.vm.CarViewModel
import com.wildma.pictureselector.PictureBean
import com.wildma.pictureselector.PictureSelector
import com.yuwei.base.BaseActivity
import com.yuwei.common.path.RouterPath
import dagger.hilt.android.AndroidEntryPoint
import java.io.File

@AndroidEntryPoint
@Route(path = RouterPath.CAR_DISTINGUISH)
class CarDistinguishActivity : BaseActivity<ActivityCarDistinguishBinding,CarViewModel>() {
    override fun initView() {
        binding.backIv.setOnClickListener {
            finish()
        }
        binding.vehicleBtn.setOnClickListener {
            PictureSelector.create(this, PictureSelector.SELECT_REQUEST_CODE).selectPicture()
        }
    }

    override fun initData() {

    }
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == PictureSelector.SELECT_REQUEST_CODE && resultCode == RESULT_OK) {
            val bundle = data?.extras
            val bean = bundle?.getParcelable<PictureBean>(PictureSelector.PICTURE_RESULT)
            val filePath = bean?.path
            Glide.with(this).load(filePath).into(binding.cameraIv)
        }
    }
}